package com.ruige.data.models.huapu.servcie.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruige.data.models.huapu.mapper.HuapuMapper;
import com.ruige.data.models.huapu.servcie.HuapuService;
import com.ruige.data.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author huangrui
 * @Description
 * @create 2020-4-17
 */
@Service
public class HuapuServiceImpl implements HuapuService {

    @Autowired
    private HuapuMapper huapuMapper;

    @Override
    public Page<SysUser> findByPage(Integer page, Integer size, Map<String, Object> map) {

        QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
        if (null != map) {
            for (String s : map.keySet()) {
                wrapper.eq(null != map.get(s), s, map.get(s));
            }
        }
//        Page<SysUser> pa = new Page(page, size);
        Page<SysUser> sysUserPage = huapuMapper.selectPage(new Page(page, size), wrapper);
        long total = sysUserPage.getTotal();
        System.out.println("total = " + total);
        return sysUserPage;
    }
}
